package com.fangshicai.controller;

import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.sql.DataSource;

/**
 * @ClassName duridController
 * @Description TODO
 * @Author fangshicai
 * @Date 2021/7/17 21:59
 */
@Controller
@Slf4j
public class duridController {
    @Autowired
    DataSource druid;
    @Autowired
    JdbcTemplate jdbcTemplate;
    @GetMapping("/sql")
    @ResponseBody
    public Object sql(){
        Long aLong = jdbcTemplate.queryForObject("SELECT count(*) FROM books.t_book;", Long.class);
//        log.info("count={}",aLong);
//        log.info("datasource={}", druid.getClass());

        return aLong;
    }
}
